package com.project.controller;

import com.project.bean.PermissionBean;
import com.project.service.IPermissionService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 权限controller
 */
@RequestMapping("permission")
@RestController
public class PermissionController {
    @Autowired
    private IPermissionService permissionService;

    //查询所有权限集合
    @RequiresPermissions("role:findPer")
    @RequestMapping("findAll")
    public List<PermissionBean> findAll(){
        return permissionService.findAll();
    }

    //通过角色id数组查询角色权限
    @RequiresPermissions({"user:*","role:*"})
    @RequestMapping("findByRoleIdArray")
    public List<PermissionBean> findByRoleIdArray(Integer[] roleIdArray){
        return permissionService.findByRoleIdArray(roleIdArray);
    }
}
